package com.kwedding.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.kwedding.dto.web.RequestWebAddBrand;
import com.kwedding.dto.web.RequestWebAddBrandSorts;
import com.kwedding.dto.web.RequestWebBrandSimple;
import com.kwedding.dto.web.RequestWebGetBrandList;
import com.kwedding.dto.web.RequestWebGetBrandSortsList;
import com.kwedding.dto.web.RequestWebInsertPermission;
import com.kwedding.dto.web.RequestWebUpDownBrand;
import com.kwedding.dto.web.RequestWebUpDownBrandStrots;
import com.kwedding.dto.web.RequestWebUpdateBrand;
import com.kwedding.dto.web.RequestWebUpdateBrandSorts;
import com.kwedding.dto.web.ResponseBrandSortsSimple;
import com.kwedding.dto.web.ResponseWebBrandList;
import com.kwedding.dto.web.ResponseWebBrandSimple;
import com.kwedding.dto.web.ResponseWebBrandSortsList;
import com.kwedding.service.web.WebBrandService;
import com.kwedding.util.BackJson;
import com.kwedding.util.JsonBack;
import com.kwedding.util.JsonBackBase;
import com.kwedding.util.LoggerParent;
import com.kwedding.util.Resp_PageInfo;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@Controller
@RequestMapping("/rest/web/brand")
@Api(tags = "Web-品牌")
public class WebBrandController extends LoggerParent {

	@Autowired
	private WebBrandService webBrandService;

	@ApiOperation(" 添加品牌分类")
	@ResponseBody
	@RequestMapping(value = "insertBrandSorts", method = { RequestMethod.POST })
	private JsonBack insertBrandSorts(@RequestBody RequestWebAddBrandSorts requestWebAddBrandSorts) {
		webBrandService.insertBrandSorts(requestWebAddBrandSorts);
		return BackJson.success();
	}

	@ApiOperation(" 获取品牌分类列表")
	@ResponseBody
	@RequestMapping(value = "getBrandSortsList", method = { RequestMethod.POST })
	private JsonBackBase<Resp_PageInfo<ResponseWebBrandSortsList>> getBrandSortsList(
			@RequestBody RequestWebGetBrandSortsList getBrandSortsList) {
		return BackJson.successObj(webBrandService.getBrandSortsList(getBrandSortsList));
	}

	@ApiOperation("修改品牌分类")
	@ResponseBody
	@RequestMapping(value = "updateBrandSorts", method = { RequestMethod.POST })
	private JsonBack updateBrandSorts(@RequestBody RequestWebUpdateBrandSorts requestWebUpdateBrandSorts) {
		webBrandService.updateBrandSorts(requestWebUpdateBrandSorts);
		;
		return BackJson.success();
	}

	@ApiOperation("上下架品牌分类")
	@ResponseBody
	@RequestMapping(value = "upDownBrandSortsSatus", method = { RequestMethod.POST })
	private JsonBack upDownBrandSortsSatus(@RequestBody RequestWebUpDownBrandStrots upDownBrandStrots) {
		webBrandService.upDownBrandSortsSatus(upDownBrandStrots);
		return BackJson.success();
	}

	@ApiOperation("添加品牌")
	@ResponseBody
	@RequestMapping(value = "insertBrand", method = { RequestMethod.POST })
	private JsonBack insertBrand(@RequestBody RequestWebAddBrand addBrand) {
		webBrandService.insertBrand(addBrand);
		return BackJson.success();
	}

	@ApiOperation("获取品牌列表")
	@ResponseBody
	@RequestMapping(value = "getBrandList", method = { RequestMethod.POST })
	private JsonBackBase<Resp_PageInfo<ResponseWebBrandList>> getBrandList(
			@RequestBody RequestWebGetBrandList brandList) {
		return BackJson.successObj(webBrandService.getBrandList(brandList));
	}

	@ApiOperation("修改品牌信息")
	@ResponseBody
	@RequestMapping(value = "updateBrand", method = { RequestMethod.POST })
	private JsonBack updateBrand(@RequestBody RequestWebUpdateBrand webUpdateBrand) {
		webBrandService.updateBrand(webUpdateBrand);
		return BackJson.success();
	}

	@ApiOperation("上下架品牌信息")
	@ResponseBody
	@RequestMapping(value = "upDownBrand", method = { RequestMethod.POST })
	private JsonBack upDownBrand(@RequestBody RequestWebUpDownBrand upDownBrand) {
		webBrandService.upDownBrand(upDownBrand);
		return BackJson.success();
	}

	@ApiOperation(" 获取可用品牌列表（用于列表选择）")
	@ResponseBody
	@RequestMapping(value = "getBrandSimpleList", method = { RequestMethod.POST })
	private JsonBackBase<List<ResponseWebBrandSimple>> getBrandSimpleList(
			@RequestBody RequestWebBrandSimple brandSimple) {
		return BackJson.successObj(webBrandService.getBrandSimpleList(brandSimple));
	}

	@ApiOperation(" 获取可用品牌分类列表（用于列表选择）")
	@ResponseBody
	@RequestMapping(value = "getBrandSortsSimpleList", method = { RequestMethod.POST })
	private JsonBackBase<List<ResponseBrandSortsSimple>> getBrandSortsSimpleList() {
		return BackJson.successObj(webBrandService.getBrandSortsSimpleList());
	}

}
